#pragma once
#include <Rz/Object.h>
#include "ISceneVisitor.h"

namespace Rz { namespace Graphics { namespace Render { namespace SceneVisitors {

class CullVisitor :
	public ISceneVisitor
{
	public:
		RZ_RTTI(Rz::Graphics::Render::SceneVisitors, CullVisitor);
		RZ_RTTI_IMPLEMENTS(ISceneVisitor);
		RZ_RTTI_END;

		virtual Scene::Node::Collection GetFinalRenderableScene() override
		{
			Scene::Node::Collection result;
			result.Clear();

			this->AddToFinalRender(result, this->GetRootNode());

			return result;
		}

	private:
		void AddToFinalRender(Scene::Node::Collection& result, Scene::Node* node)
		{
			result.Add(node);

			if (node->GetChildrenCount())
			{
				size_t count = node->GetChildrenCount();

				while (count--)
				{
					this->AddToFinalRender(result, node->GetChild(count));
				}
			}
		}
};

} } } }
